<?php

//取得该用户的论坛用户组ID
function getUser($uid){
	$ch = curl_init();
	
	
	curl_setopt($ch,CURLOPT_URL,"127.0.0.4/plugin.php?id=iltc_userinfoapi&action=user&key={$uid}");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	if(!$output = curl_exec($ch)){
		echo 'Curl error: ' . curl_error($ch);
	}
	$output =iconv("GBK", "UTF-8//ignore", $output );
	$output_array =json_decode($output,true);
	//dump($output_array);
	
	curl_close($ch);
	return $output_array['data'];
}

//取得该用户组ID的用户组名,当type=1时返回完整的用户组信息。参见 iltc_userinfoapi
function getUserGroupTitle($groupid,$type=0){
	$ch1=curl_init();
	
	curl_setopt($ch1,CURLOPT_URL,"127.0.0.4/plugin.php?id=iltc_userinfoapi&action=group");
		
	curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch1, CURLOPT_HEADER, 0);
	if(!$output1 = curl_exec($ch1)){
		echo 'Curl error: ' . curl_error($ch1);
	}
	$output1 =iconv("GBK", "UTF-8//ignore", $output1 );
	$output_array1 =json_decode($output1,true);
	curl_close($ch1);
	foreach($output_array1['data'] as $key=>$val){
		if($groupid==$val['groupid']){
			$grouptitle=$val['grouptitle'];
			$group=$val;
		}
	}
	//dump($output_array1);
	if($type==0){
		return $grouptitle;
	}else if($type==1)return $group;
	
}